package com.moliku.insurance.common.exception;


import com.moliku.insurance.common.response.ResponseCode;
import lombok.Getter;


/**
 * 业务异常
 *
 * @author Mr.Liu
 * @since 2020-02-03
 */
public class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 2359767895161832954L;

    @Getter
    private final ResponseCode responseCode;

    public ServiceException(String message) {
        super(message);
        this.responseCode = ResponseCode.FAILURE;
    }

    public ServiceException(String message, ResponseCode resultCode) {
        super(message);
        this.responseCode = resultCode;
    }

    public ServiceException(ResponseCode resultCode) {
        super(resultCode.getMessage());
        this.responseCode = resultCode;
    }

    /**
     * 提高性能
     *
     * @return Throwable
     */
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
